// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: donggu

#include <memory>

#include "orio/io/file.h"
#include "orio/record/topic.h"

using orio::io::FileReader;
using orio::io::Reader;
using orio::record::TopicReader;
using orio::record::TopicRecord;

int main(int /*argc*/, char* argv[]) {
  std::unique_ptr<Reader<TopicRecord>> reader(
      TopicReader::FromFile(argv[1], 16 * 1024 * 1024, false));
  std::unique_ptr<std::byte[]> buf(new std::byte[16 * 1024 * 1024]);
  auto* record = reinterpret_cast<TopicRecord*>(buf.get());

  uint64_t size = 0;
  while (reader->Read(record)) {
    size++;
  }

  printf("decompresed size: %lu bytes\n", size);

  return 0;
}
